/**
 * 
 * @file_name jHashMap-0.1.gaopeng.js
 * @Description: TODO  JhashMap 类的封装
 * @author wenwei.wan@gaopeng.com
 * @date 2011-9-19 下午6:49:34 
 * @returns {JhashMap}
 */
function JhashMap(){
	this.length = 0;
	this.prefix = "hashMap_www_2011";
}
/**
 * 向HashMap中添加键值
 */
JhashMap.prototype.put = function(key,value){
	this[this.prefix+key] = value;
	this.length++;
};
/**
 * 从haspMap中获取value
 */
JhashMap.prototype.get = function(key){
	return (typeof this[this.prefix+key]=='undefined'?null:this[this.prefix+key]);
};
/**
 * 从haspMap获取所有的key集合，以数组形式返回
 */
JhashMap.prototype.keySet=function(){
	var arrKeySet = new Array();
	for(var obj in this){
		if(obj.substring(0,this.prefix.length)==this.prefix)
			arrKeySet.push(obj.substring(this.prefix.length));
	}
	this.length = arrKeySet.length;
	return arrKeySet.length==0?null:arrKeySet;
};
/**
 * 从haspMap中获取所有的value集合，以数组形式返回
 */
JhashMap.prototype.values = function(){
	var arrValues = new Array();
	for(var obj in this){
		if(obj.substring(0,this.prefix.length)==this.prefix)
			arrValues.push(this[obj]);
	}
	this.length = arrValues.length;
	return arrValues.length==0?null:arrValues;
};
/**
 * 获取haspMap的数量
 */
JhashMap.prototype.size = function(){
	return this.length;
};
/**
 * 删除指定的值
 */
JhashMap.prototype.remove = function(key){
	delete this[this.prefix+key];
	this.length--;
};
/**
 * 清空hashMap
 */
JhashMap.prototype.clear = function(){
	for(var obj in this){
		if(obj.substring(0,this.prefix.length)==this.prefix)
			delete this[obj];
	}
};
/**
 * 判断是否为空
 */
JhashMap.prototype.isEmpty = function(){
	return this.length==0;
};
/**
 * 判断HashMap是否存在某个key
 */
JhashMap.prototype.containKey = function(key){
	for(var obj in this){
		if(obj==this.prefix+key)
			return true;
	}
	return false;
};
/**
 * 判断HashMap是否存在某个value
 */
JhashMap.prototype.containValue = function(value){
	for(var obj in this){
		if(obj==this.prefix+key)
			return true;
	}
	return false;
};
/**
 * 把一个HashMap的值加入到另一个HashMap中，参数必须是HashMap
 */
JhashMap.prototype.putAll = function(map){
	if(map==null||map.constructor!=JhashMap) return;
	var arrKey = map.keySet();
    var arrValue = map.values();
    for(var i in arrKey)
    	this.put(arrKey[i],arrValue[i]);
};
/**
 * toString
 */
JhashMap.prototype.toString = function(){
    var str = "";
    for(var strKey in this){
        if(strKey.substring(0,this.prefix.length) == this.prefix)
              str+=strKey.substring(this.prefix.length)+":"+this[strKey]+"\r\n";
    }
    return str;
};